/*
 * NetRayt
 * Copyright (c) 2007-2008 Maciej Nabozny.
 *
 * NetRayt is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * NetRayt is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with NetRayt; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

#ifndef _ARGLIST_CPP
#define _ARGLIST_CPP

#include "conn.h"

/*******************************************/
/*          Klasa listy argumentów         */
/*******************************************/
void argList::set(const QString name, const QString value) {
	argNode *tmp = head;
	while (tmp->next != NULL) {
		// przypisz wartosc juz istniejącemu elementowi
		if (tmp->name == name) {
			tmp->value=value;
			return;
		}
		tmp=tmp->next;
	}
	
	// ustaw nowy element listy
	tmp->next = new argNode;
	tmp->next->name = name;
	tmp->next->value = value;
	tmp->next->next = NULL;
}

QString argList::read(const QString name) {
	argNode *tmp = head;
	while (tmp != NULL) {
		if (tmp->name == name) {
			return tmp->value;
		}
		tmp=tmp->next;
	}
	
	return head->value;
}

QString argList::toTag() {
	QString r = "";
	argNode *tmp = head->next;
	while (tmp != NULL) {
		r += " " + tmp->name + "=\"" + tmp->value + "\"";
		
		tmp = tmp->next;
	}
	
	return r;
}

#endif

